#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    , m_pthread(new MyThread)
{
    ui->setupUi(this);

    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::caculatbtn_clicked);

    //使用信号与槽实现线程间的通信
    connect(m_pthread, &MyThread::caculate_over, this, &Widget::show_rst);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::caculatbtn_clicked(){
    m_pthread->start();

    qDebug() << "main thread excute" ;

    return;

}

void Widget::show_rst(long long rst){
    ui->lineEdit->setText(QString::number(rst));
    return;
}

